from svqbak import SVQ
import svq
from classes import *


def calcF(x,m):
    Beta = 0.002
    Sum = []
    #for j in m:
    tmp_sum = 0
    for point in range(len(x)):
        for cord in range(len(x[point])):
            tmp_sum += ( x[point][cord] -  m[point][cord] )**2
            #print 'tmp_sum', tmp_sum,x[point][cord],j[point][cord]
    Sum.append(math.exp( -Beta * tmp_sum))
    sum_ = sum(Sum)
    #if len(self.m) == 4:
    print 'sum_ Sum ',sum_, Sum, tmp_sum
    #F = [Sum[i]/sum_ for i in range(len(m))]
    F = Sum[0]/sum_
    return F


if __name__ == "__main__":

    #    cb_svq = SVQ(4,points,0.002,0.5) #0.0002
    m =[ [233.47432230064334, 87.416857967978416],
    [155.12014063905556, 46.828193407825424],
    [94.149476256606221, 219.16896241290351],
    [224.89899940825771, 192.24977957903613],
    [57.588649520183651, 96.990594195029132],
    [157.44551102513159, 259.60924887390991],
    [151.43779953538643, 138.0878804137825],
    [156.99401546165254, 97.821277082922791],
    [97.39430840240513, 100.85033626103211],
    [202.34625760841286, 132.58759767160726],
    [69.94501274174354, 186.03992161327838],
    [67.279627969501405, 140.5879030584324],
    [235.2157144128565, 140.91078827645615],
    [113.99471058198368, 67.365884222937098],
    [196.84483933172294, 230.11516245729172],
    [186.06876413751829, 76.755685463583319],
    [180.27259623865044, 180.4207348678197],
    [144.91416478466411, 208.03017107615594],
    [125.7031702662254, 245.20438834948823],
    [119.93831927511337, 164.54711730274784],
    ]
    x = [
    [156.88126904337133, 77.616059302262855],
    [157.58662674401364, 40.270913161615624],
    [156.97694848238899, 72.076875971069398],
    [158.94295816456014, 123.93694382315356],
    [155.78456287096193, 145.9591641166534],
    [158.7997840578951, 125.92442980481917],
    [129.30303874732738, 264.44894463309635],
    [178.43117486656914, 242.8460517205493],
    [180.26138857237308, 265.59302577819648],
    [180.26499961291361, 265.58991140315862],
    [138.24140645548172, 210.63286099949198],
    [163.86763509624356, 184.61155141511685],
    [154.74442492644437, 174.65866336000704],
    [179.03783927179549, 206.86516151492577],
    [177.02398719434677, 227.71569299890621],
    [151.01367910385869, 257.00382598930094],
    [129.31959361224139, 264.5636533113107],
    [156.32764072759073, 82.889644483101804],
    [132.04335512976417, 238.20961326770205],
    [138.53582712594152, 209.1162246215859]]
    print calcF(x,m)